package com.minibobbo.utilities.extrectangle;

import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.math.Vector2;

public class eRectangle extends Rectangle {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public eRectangle(float x, float y, float width, float height) {
		super(x, y, width, height);
	}

	public eRectangle() {
		super();
	}

	/**
	 * Gets the X value of the left side of this rectangle.
	 * 
	 * @return The X value
	 */
	public float getLeftSide() {
		return this.x;
	}

	/**
	 * Gets the X value of the right side of this rectangle.
	 * 
	 * @return The X value
	 */
	public float getRightSide() {
		return this.x + this.width;
	}

	/**
	 * Gets the Y value of the top of the rectangle.
	 * 
	 * @return The y value
	 */
	public float getTopSide() {
		return y + height;
	}

	/**
	 * Gets the Y value of the bottom of the rectangle.
	 * 
	 * @return The Y value
	 */
	public float getBottomSide() {
		return y;
	}
	
	/**
	 * Gets the center of the rectangle
	 * @return Vector2 of the center of the rectangle
	 */
	public Vector2 getCenter() {
		return new Vector2(x + (width/2), y + (height /2));
	}
	
	

	/**
	 * Gets the lower left value of the rectangle
	 * 
	 * @return Vector2 of the lower left point
	 */
	public Vector2 getLL() {
		return new Vector2(x, y);
	}

	/**
	 * Gets the lower right value of the rectangle.
	 * 
	 * @return Vector2 of the lower right point
	 */
	public Vector2 getLR() {
		return new Vector2(x + width, y);
	}

	/**
	 * Gets the upper left value of the rectangle
	 * 
	 * @return Vector2 of the upper left point
	 */
	public Vector2 getUL() {
		return new Vector2(x, y + height);
	}

	/**
	 * Gets the upper right value of the rectangle
	 * 
	 * @return Vector2 of the upper right point
	 */
	public Vector2 getUR() {
		return new Vector2(x + width, y + height);
	}

	/**
	 * Adjusts the rectangle so the bottom lines up with the supplied value.
	 * This does not change the horizontal position.
	 * 
	 * @param bottom
	 *            The value to set the bottom of the rectangle.
	 */
	public void setBottom(float bottom) {
		y = bottom;
	}
	
	public void setTop(float top) {
		y=  top - height;
	}
	
	public void setLeft(float left) {
		x = left;
	}
	
	public void setRight(float right) {
		x = right - width;
	}
	
	/**
	 * Sets the rectangle with the center at the supplied coordinates.
	 * @param x The center of the rectangle
	 * @param y The center of the rectangle
	 * @param width The rectangle width
	 * @param height The rectangle height
	 */
	public void setWithCenter(float x, float y, float width, float height) {
		this.set(x - (width/2), y - (height/2), width, height);
	}
}
